package com.eazyshop.search.listener;


import com.eazyshop.search.controller.SkuController;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 监听"goods_up_queue"队列
 * 如果这个队列中有新的消息
 * 说明有新的商品上架了需要添加文档到对应的索引库中
 */
@Component
public class GoodsOnShelfListener {

    @Autowired
    private SkuController skuController;

    @RabbitListener(queues = "goods_up_queue")
    public void productListingMonitoring(String message){
            // message为添加商品的spuID
        skuController.importSkuBySpuId(message);
        System.out.println("上架商品已导入到es中");
    }
}
